package controller.common;

import domain.entity.base.BaiduInfo;
import domain.service.base.ValidationService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by bowen on 2017-08-14.
 */

@Controller
public class ValidationController {

    private static final Logger logger = Logger.getLogger(ValidationController.class);
    @Autowired
    private ValidationService validationService;

//    @ResponseBody
//    @RequestMapping(value = "/getJsTicket")
//    public Map<String, Object> getWeJsTicket(String url) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        try {
//            return validationService.getSignature(url);
//        } catch (Exception e) {
//            this.logger.error(e.getMessage());
//        }
//        return map;
//    }

    @ResponseBody
    @RequestMapping(value = "/getBaiduInfo")
    public Map<String, Object> getBaiduInfo(float latitude, float longitude) {
        Map<String, Object> map = new HashMap<String, Object>();
        try {
            BaiduInfo info = validationService.getBaiduInfo(latitude, longitude);
            map.put("status", "201");
            map.put("data", info);
        } catch (Exception e) {
            map.put("status", "202");
            this.logger.error(e.getMessage());
        }
        return map;
    }


}
